{% extends "base.html" %}

{% block title %}{% if register %}用户注册{% else %}用户登录{% endif %} - 智能推荐系统{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6 col-lg-5">
            <div class="card shadow">
                <div class="card-header bg-primary text-white text-center">
                    <h4 class="mb-0">
                        <i class="fas fa-{% if register %}user-plus{% else %}sign-in-alt{% endif %} me-2"></i>
                        {% if register %}用户注册{% else %}用户登录{% endif %}
                    </h4>
                </div>

                <div class="card-body p-4">
                    {% if register %}
                    <!-- 注册表单 -->
                    <form method="POST" action="{{ url_for('register') }}">
                        <div class="mb-3">
                            <label for="username" class="form-label">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" required>
                        </div>

                        <div class="mb-3">
                            <label for="email" class="form-label">邮箱</label>
                            <input type="email" class="form-control" id="email" name="email" required>
                        </div>

                        <div class="mb-3">
                            <label for="password" class="form-label">密码</label>
                            <input type="password" class="form-control" id="password" name="password" required>
                        </div>

                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-user-plus me-1"></i>注册
                            </button>
                        </div>
                    </form>

                    <div class="text-center mt-3">
                        <p class="mb-0">已有账户？ <a href="{{ url_for('login') }}">立即登录</a></p>
                    </div>

                    {% else %}
                    <!-- 登录表单 -->
                    <form method="POST" action="{{ url_for('login') }}">
                        <div class="mb-3">
                            <label for="username" class="form-label">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" required>
                        </div>

                        <div class="mb-3">
                            <label for="password" class="form-label">密码</label>
                            <input type="password" class="form-control" id="password" name="password" required>
                        </div>

                        <div class="d-grid">
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-sign-in-alt me-1"></i>登录
                            </button>
                        </div>
                    </form>

                    <div class="text-center mt-3">
                        <p class="mb-0">没有账户？ <a href="{{ url_for('register') }}">立即注册</a></p>
                    </div>

                    <!-- 演示账户 -->
                    <hr>
                    <div class="text-center">
                        <p class="text-muted mb-2">演示账户：</p>
                        <small class="text-muted">
                            用户名: demo | 密码: demo123<br>
                            管理员: admin | 密码: admin123
                        </small>
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}